// 发送请求

import axios from "axios";
import showMessage from "@/utils/showMessage";

const ins = axios.create(); // 创建一个axios的实例
ins.interceptors.response.use(function (resp) {
  // console.log("请求参数:", resp.request.responseURL);
  // console.log("请求路径:", resp.config.url, "请求类型:", resp.config.method, "\n响应结果:", resp.data.data);
  if (resp.data.code !== 0) {
    showMessage({
      content: resp.data.msg,
      type: "error",
      duration: 2000,
    });
    return null;
  }
  return resp.data.data;
});

export default ins;
